<template>
  <div>
    <el-card>
      <div class="ding">
        题目名称:<el-input v-model="queryInfo.input" placeholder="请输入内容" clearable @input="search" @clear="clear" />
        <el-button type="primary" @click="fan">返回</el-button>
      </div>
      <el-table
        :data="weitable"
        style="width: 100%"
      >
        <el-table-column
          label="序号"
          type="index"
          width="130px"
        />
        <el-table-column
          label="题目"
          prop="title"
        />
        <el-table-column
          label="类别"
        >
          <template slot-scope="scope">
            {{ scope.row.cata_o.cateName }}
          </template>
        </el-table-column>
        <el-table-column
          label="上传者"
          prop="uploder"
        />
        <el-table-column
          label="上传状态"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.status==2" class="red">未通过审核</span>
            <!-- <span v-else class="blue">审核通过</span> -->
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200px">
          <template slot-scope="scope">
            <el-button @click="xq(scope.row)"><a class="blue">详情</a></el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-pagination
        :page-sizes="[5, 10, 15, 20]"
        :page-size="5"
        layout="total, sizes, prev, pager, next, jumper"
        :total="queryInfo.t"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-card>
  </div>
</template>

<script>
export default {
  components: {},
  props: {},
  data() {
    return {

      weitable: [],
      queryInfo: {
        size: 5,
        page: 1,
        t: 0,
        input: ''
      },
      pageisornot: false
    }
  },
  computed: {

  },
  watch: {},
  created() {
    this.getqst()
  },
  mounted() {},
  methods: {
    async getqst() {
      var res = await this.http.get('/knowledge/ques/', { params: this.queryInfo })

      if (res.data.code == 200) {
        res.data.data.forEach(element => {
          if (element.status == 2) {
            this.weitable.push(element)
          }
        })
        // this.weitable=res.data.data
        this.queryInfo.t = this.weitable.length
      }
    },
    async search() {
      this.getqst()
    },
    clear() {
      this.getqst()
    },
    fan() {
      this.$router.go(-1)
    },
    xq(row) {
      this.$router.push({ path: '/xq', query: { id: row.id }})
    },
    handleSizeChange(v) {
      this.queryInfo.size = v
      this.getqst()
    },
    handleCurrentChange(v) {
      this.queryInfo.page = v
      this.getqst()
    }
  }
}
</script>
<style  scoped>
    .el-input{
      width: 200px;
      margin-left: 5px;
    }
    .el-pagination{
      margin-top: 20px;
      text-align: center;
    }
    .el-table .el-button{
      background: 0;
      padding-left: 0;
      padding-right: 0;
      display: inline-block;
      border:0;
    }
    .blue{
      color: #3175fb;
    }
    .red{
      color: red;
    }
    .ding .el-button{
        float: right;
    }
</style>
